package com.ruoyi.erp.service.impl;

import cn.hutool.core.date.DateUtil;
import cn.hutool.json.JSONUtil;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.erp.controller.LedyFeeCheckinController;
import com.ruoyi.erp.domain.GlAccvouch;
import com.ruoyi.erp.domain.GlCashtable;
import com.ruoyi.erp.service.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;

@Service("taskService") // 必须有Spring Bean标识（@Service/@Component）
public class TaskServiceImpl {
    protected final Logger logger = LoggerFactory.getLogger(this.getClass());
    @Autowired
    private ILedyFeeCheckinService ledyFeeCheckinService;
    @Autowired
    private IGlAccvouchService glAccvouchService;
    @Autowired
    private ILedyBacFeeConfigService configService;
    @Autowired
    private ICustomerService customerService;
    @Autowired
    private IGlCashtableService cashtableService;
    /**
     * 12月1日执行的任务方法（无参示例）
     */
    public void executeDecemberFirstTask() {

        System.out.println("===== 12月1日定时任务执行 =====");
        // 这里写具体业务逻辑（如数据统计、清理等）

    }

    /**
     * 带参任务示例（可选）
     */
    public void executeTaskWithParams(String ids,String type,String dbillDate,Integer iperiod) {
        Long[] idArray = Arrays.stream(ids.split(","))
                .map(String::trim)
                .filter(StringUtils::isNotEmpty)
                .map(Long::parseLong)
                .toArray(Long[]::new);
        LedyFeeCheckinController.faSync(idArray, type, dbillDate, iperiod,glAccvouchService,ledyFeeCheckinService,configService,customerService,cashtableService);
        logger.info("===== 12月1日定时任务执行 ====="+ iperiod+dbillDate );
    }
}